package com.woniu.humanresource.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.humanresource.entity.Accets;
import com.woniu.humanresource.entity.ResponseText;
import com.woniu.humanresource.service.AccetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class AccetsController {
    @Autowired
    AccetsService accetsService;
    //分页条件查询
    @PostMapping("/accets/{pageIndex}/{pageSize}")
    public ResponseText<Page<Accets>> getAllAccetsPageBean(@PathVariable("pageIndex") int pageIndex,
                                                           @PathVariable("pageSize") int pageSize,
                                                           @RequestBody Accets accets){

        System.out.println("■■■■■■查询■■■■■■"+accets);

        Page<Accets> allAccets = accetsService.getAllAccets(pageIndex,pageSize,accets);

        ResponseText<Page<Accets>> responseText=new ResponseText<>(allAccets, 200, "OK");

        return responseText;
    }
    //单个删除
    @DeleteMapping("/accets/{accetsId}")
    public ResponseText<Page<Accets>> removeAccetsById(@PathVariable("accetsId") int accetsId){

        System.out.println("■■■■■■单个删除■■■■■■"+accetsId);

        accetsService.removeAccetsById(accetsId);

        ResponseText<Page<Accets>> responseText=new ResponseText<>(null, 200, "OK");

        return responseText;
    }
    //批量删除
    @DeleteMapping("/accets")
    public ResponseText<Page<Accets>> removeMultipleAccetsById(@RequestBody List<Accets> accets){

        System.out.println("■■■■■■批量删除■■■■■■"+"【参数长度:"+accets.size()+"】具体参数:"+accets);

        accetsService.removeMultipleAccetsById(accets);

        ResponseText<Page<Accets>> responseText=new ResponseText<>(null, 200, "OK");

        return responseText;
    }
}
